﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using diploma.core.data.objects;
using diploma.core.data;

namespace diploma.test.GUI
{
    enum PropertyObjectType : long
    {
        theorem = 1,
        lemma = 2,
        comment = 3,
        suggestion = 4,
        problem = 5,
        definition = 6,
        axiom = 7,
        method = 8,
        function = 9,
        set = 10
    }
    public partial class ObjectForm : Form
    {
        Property prop = null;
        public ObjectForm(DataList<diploma.core.data.IDataObject> themes)
        {
            InitializeComponent();
            comboBox2.Items.AddRange(Enum.GetNames(typeof(PropertyObjectType)));
            comboBox1.Items.AddRange(themes.ToArray());
            comboBox1.SelectedIndex = 0;
            comboBox2.SelectedIndex = 0;
        }

        public ObjectForm(DataList<diploma.core.data.IDataObject> themes, Property obj)
        {
            InitializeComponent();
            prop = obj;
            comboBox1.Items.AddRange(Enum.GetValues(typeof(PropertyObjectType)) as object[]);
            comboBox2.Items.AddRange(themes.ToArray());
        }


        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Text != "")
            {
                if (prop == null)
                {
                    long i = (long)Enum.Parse(typeof(PropertyObjectType), comboBox2.SelectedItem.ToString());
                    prop = new Property(-1, textBox1.Text, (comboBox1.SelectedItem as Theme).Id, (long)Enum.Parse(typeof(PropertyObjectType), comboBox2.SelectedItem.ToString()));
                }
                else
                {
                    prop = new Property(prop.Id, textBox1.Text, (comboBox1.SelectedItem as Theme).Id, (long)Enum.Parse(typeof(PropertyObjectType), comboBox2.SelectedItem.ToString()));
                }
                Close();
            }
        }

        public Property Prop
        {
            get
            {
                return prop;
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            Close();
        }


    }
}
